package com.dhl.fin.api.enums;

import com.dhl.fin.api.common.util.SpringContextUtil;
import com.dhl.fin.api.service.*;
import com.dhl.fin.api.service.cronService.*;
import lombok.Getter;

/**
 * @author CuiJianbo
 * @since 2025/5/6
 */
@Getter
public enum RemindCycleTypeEnum {

    ONE_TIMES("一次性", OneTimesCron.class),

    EVERY_DAY("每天", EveryDayCron.class),

    EVERY_WEEK("每周", EveryWeekCron.class),

    EVERY_MONTH("每月", EveryMonthCron.class),

    EVERY_YEAR("每年", EveryYearCron.class);

    private String name;

    private Class<? extends RemindCron> clazz;

    RemindCycleTypeEnum(String name, Class<? extends RemindCron> clazz) {
        this.name = name;
        this.clazz = clazz;
    }

    public static RemindCron getRemindCycleTypeRemindCron(String name) {
        RemindCycleTypeEnum[] values = RemindCycleTypeEnum.values();
        for (RemindCycleTypeEnum value : values) {
            if (value.name.equals(name)) {
                return SpringContextUtil.getBean(value.clazz);
            }
        }
        return null;
    }
}
